#include "stdafx.h"
#include "StructDefs.h"



template<class T>
void VectorToAngle(CPoint3D<T>& vec,float& fPdir,float& fAdir)
{
	//polar angle
	fPdir=atan2(sqrt(vec.x*vec.x+vec.z*vec.z),vec.y);

	//azimuthal angle
	fAdir=atan2(-vec.z,vec.x);
	if (fAdir<0) fAdir+=2*float(Pi);
}
//------------------------------------------------------------------------------
// CVectors blend product
//------------------------------------------------------------------------------
template<class T>
float blend_product(CPoint3D<T> &v1, CPoint3D<T> &v2, CPoint3D<T> &v3)
{
	return( ( v1 * v2 ) & v3 );
}

//------------------------------------------------------------------------------
// bulid a normal by three 3D points
//------------------------------------------------------------------------------
template<class T>
CPoint3D<T>	BuildNormal( CPoint3D<T> &p1, CPoint3D<T> &p2, CPoint3D<T> &p3 )
{
	return ( ( p3-p2 ) * ( p1-p2 ) );
}
